import 'dart:convert';

//射频读取端口及对应的工具柜Id
class AntennaInfo {
  String id;
  String toolKitId; //工具柜ID
  String antennaPort; //射频端口号
  AntennaInfo({
    required this.id,
    required this.toolKitId,
    required this.antennaPort,
  });

  AntennaInfo copyWith({
    String? id,
    String? toolKitId,
    String? antennaPort,
  }) {
    return AntennaInfo(
      id: id ?? this.id,
      toolKitId: toolKitId ?? this.toolKitId,
      antennaPort: antennaPort ?? this.antennaPort,
    );
  }

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'toolKitId': toolKitId,
      'antennaPort': antennaPort,
    };
  }

  factory AntennaInfo.fromMap(Map<String, dynamic> map) {
    return AntennaInfo(
      id: map['id'] ?? '',
      toolKitId: map['toolKitId'] ?? '',
      antennaPort: map['antennaPort'] ?? '',
    );
  }

  String toJson() => json.encode(toMap());

  factory AntennaInfo.fromJson(String source) =>
      AntennaInfo.fromMap(json.decode(source));

  @override
  String toString() =>
      'AntennaInfo(id: $id, toolKitId: $toolKitId, antennaPort: $antennaPort)';

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;

    return other is AntennaInfo &&
        other.id == id &&
        other.toolKitId == toolKitId &&
        other.antennaPort == antennaPort;
  }

  @override
  int get hashCode => id.hashCode ^ toolKitId.hashCode ^ antennaPort.hashCode;
}
